﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class DepartmentScore : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Get dpt id from 
        string userName = (string)Session[Engine.m_Usnkey];
        StaffDB stfdb = new StaffDB();
        StaffDetail staffInfo = stfdb.GetStaffBySNum(int.Parse(userName));
        ObjectDataSource_Dpt.SelectParameters["DepartmentNum"].DefaultValue = staffInfo.DepartmentNum.ToString();

    }
    protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
    {
        if (Utility.HasNullValue(e.NewValues))
        {
            ((Label)Page.Master.FindControl("ErrorLabel")).Text = "输入不能为空！";
            e.Cancel = true;
            return;
        }

        string score = e.NewValues["Score"].ToString();
        bool valid = true;
        int result;
        if (!int.TryParse(score, out result) || result < 0 || result > 100)
        {
            valid = false;
        }

        // Set the error message label.
        if (!valid)
        {
            ((Label)Page.Master.FindControl("ErrorLabel")).Text = "请确定评分在0~100之间。";
            e.Cancel = true;
        }
        else
            ((Label)Page.Master.FindControl("ErrorLabel")).Text = "";
    }
}
